package com.beimi.game.module;

import java.util.ArrayList;
import java.util.List;

import com.beimi.game.action.IAction;

public class GameUserCmdModule {
	
	private List<IAction> newCmds;
	private List<IAction> commands;
	
	public GameUserCmdModule(){
		commands = new ArrayList<>();
		newCmds = new ArrayList<>();
	}

	public void add(IAction action) {
		synchronized (newCmds) {
			newCmds.add(action);
		}
	}

	public List<IAction> getCommands() {
		synchronized (newCmds) {
			commands.addAll(newCmds);
			newCmds.clear();
			return commands;
		}
	}

	public void setComands(List<IAction> commands) {
		this.commands = commands;
	}
}
